<?php

namespace App\Http\Controllers\Test;

use App\Facade\Elastic\ElasticsearchFacade;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class EsTestController extends Controller
{
    //
    public function index(){
        $ret = [];
        // $ret = ElasticsearchFacade::createIndex('article1212'); //创建索引
        // $ret = ElasticsearchFacade::indexExists('article6666'); //索引是否存在
        // $ret = ElasticsearchFacade::deleteIndex('article1111'); //删除索引
        // 创建或者修改索引
        // $data = ['title' => '测试标题','content' => '测试内容',];
        // $ret = ElasticsearchFacade::indexDocument('article666999','666',$data); //获取索引设置
        // $ret = ElasticsearchFacade::getDocument('article666999','666'); //获取索引设置
        // $ret = ElasticsearchFacade::deleteDocument('article666999','666'); //删除索引设置
        // $ret = ElasticsearchFacade::getDocumentCount('index_orders'); //获取文档数量
        
        $where = [];
        // $where[] = ['id','=','745717']; //根据指定id查询
        // $where[] = ['source','=','拼多多-硕运通讯专营店']; //根据指定id查询
        // $where[] = ['id', 'in', [2865981, 745717, 2865976]];
        // $where[] = ['status', '>=', 13];
        // $where[] = ['status', '<=', 6];
        // $where[] = ['dt_add', '>=', 1741274212];
        // $where[] = ['id', 'in', ['745717']];
        // $where[] = ['orderid.keyword', 'in', ['250306-537185523290683','202201011234Z','221113-347238624700935']]; //根据指定id查询 text需要追加 .keyword
        // $where[] = ['title','like','非无限量低月租']; 
        $sort = ['dt_add'=>'desc'];
        $count = ElasticsearchFacade::getDocumentCount('order_full_0729',$where);
        $ret = ElasticsearchFacade::search('order_full_0729',$where,$sort,1,40);
        p($count);
        p($ret);
    }
}
